﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaixin.Components.InterFace;
using Kaixin.Components.XML;
using Kaixin.Components.DTO;
using Kaixin.Components.Master.BLL;
using Kaixin.Components.Master.DTO;

namespace Kaixin.Components.Master.PanelFactory
{
    class MasterInfoPanelFactory: IUIPanelFactory
    {
        private UserSet _us = new UserSet();

        private void InitializeComponent()
        {
            this.ktpanel = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
            this.kryptonPanel1 = new ComponentFactory.Krypton.Toolkit.KryptonPanel();
            this.kryptonLabel1 = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.lblLevel = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.lblUpdate = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.kryptonComboBox1 = new ComponentFactory.Krypton.Toolkit.KryptonComboBox();
            this.kryptonLabel2 = new ComponentFactory.Krypton.Toolkit.KryptonLabel();
            this.dgvData = new ComponentFactory.Krypton.Toolkit.KryptonDataGridView();
            this.btnSearch = new ComponentFactory.Krypton.Toolkit.KryptonButton();
          
            // 
            // ktpanel
            // 
            this.ktpanel.Controls.Add(this.dgvData);
            this.ktpanel.Controls.Add(this.kryptonPanel1);
            this.ktpanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.ktpanel.Location = new System.Drawing.Point(0, 0);
            this.ktpanel.Name = "ktpanel";
            this.ktpanel.Size = new System.Drawing.Size(992, 568);
            this.ktpanel.TabIndex = 0;
            // 
            // kryptonPanel1
            // 
            this.kryptonPanel1.Controls.Add(this.btnSearch);
            this.kryptonPanel1.Controls.Add(this.kryptonLabel2);
            this.kryptonPanel1.Controls.Add(this.kryptonComboBox1);
            this.kryptonPanel1.Controls.Add(this.lblUpdate);
            this.kryptonPanel1.Controls.Add(this.lblLevel);
            this.kryptonPanel1.Controls.Add(this.kryptonLabel1);
            this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.kryptonPanel1.Location = new System.Drawing.Point(0, 0);
            this.kryptonPanel1.Name = "kryptonPanel1";
            this.kryptonPanel1.Size = new System.Drawing.Size(992, 100);
            this.kryptonPanel1.TabIndex = 0;
            // 
            // kryptonLabel1
            // 
            this.kryptonLabel1.Location = new System.Drawing.Point(251, 14);
            this.kryptonLabel1.Name = "kryptonLabel1";
            this.kryptonLabel1.Size = new System.Drawing.Size(57, 18);
            this.kryptonLabel1.TabIndex = 0;
            this.kryptonLabel1.Values.Text = "我的信息";
            // 
            // lblLevel
            // 
            this.lblLevel.Location = new System.Drawing.Point(302, 29);
            this.lblLevel.Name = "lblLevel";
            this.lblLevel.Size = new System.Drawing.Size(57, 18);
            this.lblLevel.TabIndex = 1;
            this.lblLevel.Values.Text = "当前等级";
            // 
            // lblUpdate
            // 
            this.lblUpdate.Location = new System.Drawing.Point(302, 53);
            this.lblUpdate.Name = "lblUpdate";
            this.lblUpdate.Size = new System.Drawing.Size(80, 18);
            this.lblUpdate.TabIndex = 2;
            this.lblUpdate.Values.Text = "还有几场升级";
            // 
            // kryptonComboBox1
            // 
            this.kryptonComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.kryptonComboBox1.DropDownWidth = 121;
            this.kryptonComboBox1.Location = new System.Drawing.Point(84, 12);
            this.kryptonComboBox1.Name = "kryptonComboBox1";
            this.kryptonComboBox1.Size = new System.Drawing.Size(121, 21);
            this.kryptonComboBox1.TabIndex = 3;

            // 
            // kryptonLabel2
            // 
            this.kryptonLabel2.Location = new System.Drawing.Point(10, 15);
            this.kryptonLabel2.Name = "kryptonLabel2";
            this.kryptonLabel2.Size = new System.Drawing.Size(68, 18);
            this.kryptonLabel2.TabIndex = 4;
            this.kryptonLabel2.Values.Text = "被监控用户";
            // 
            // dgvData
            // 
            this.dgvData.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dgvData.Location = new System.Drawing.Point(0, 100);
            this.dgvData.Name = "dgvData";
            this.dgvData.RowTemplate.Height = 23;
            this.dgvData.Size = new System.Drawing.Size(992, 468);
            this.dgvData.TabIndex = 1;
            // 
            // btnSearch
            // 
            this.btnSearch.Location = new System.Drawing.Point(12, 53);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(90, 25);
            this.btnSearch.TabIndex = 2;
            this.btnSearch.Values.Text = "查询";
            btnSearch.Click += new EventHandler(btnSearch_Click);

        }

        void btnSearch_Click(object sender, EventArgs e)
        {
            if (kryptonComboBox1.SelectedItem!=null)
            {
                User user = (User)kryptonComboBox1.SelectedItem;
                MasterRobot mr = new MasterRobot(user.Email, user.Password);
                dgvData.DataSource = mr.GetMyOpponents();

                MyInfo info = mr.GetMyInfo();
                lblLevel.Text = "当前等级" + info.Level + "级";
                lblUpdate.Text = info.UPcount;
            }
        }


        #region IUIPanelFactory 成员

        public System.Windows.Forms.Panel CreatePanel()
        {
            InitializeComponent();


            List<User> list = _us.GetAllItem();
            kryptonComboBox1.DataSource = list;
            kryptonComboBox1.DisplayMember = "Email";
            kryptonComboBox1.ValueMember = "Password";

            return ktpanel;
        }

        #endregion

        private ComponentFactory.Krypton.Toolkit.KryptonPanel ktpanel;
        private ComponentFactory.Krypton.Toolkit.KryptonPanel kryptonPanel1;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel kryptonLabel1;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel lblLevel;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel lblUpdate;
        private ComponentFactory.Krypton.Toolkit.KryptonLabel kryptonLabel2;
        private ComponentFactory.Krypton.Toolkit.KryptonComboBox kryptonComboBox1;
        private ComponentFactory.Krypton.Toolkit.KryptonDataGridView dgvData;
        private ComponentFactory.Krypton.Toolkit.KryptonButton btnSearch;
    }
}
